
************************************************************************************************************************************************
****************************** REPLICATION CODE: RELIGION AND BRAZILIAN POLITICS 
****************************** 2019. Cambridge University Press
****************************** By Amy Erica Smith (amyericas@gmail.com) 

****************************** ANALYSIS OF BEPS 2010 DATA



****************************************** VARIABLE CODING **************************************************************************************
****************************** CROSSES AND CULTURE WARS DATA SET-UP
****************************** SET UP BEPS 2010 DATA 

use "C:\Users\aesmith2\Dropbox\Work\Data\BEPS 2010\Waves 1-3 data\BEPSwaves123_long_withstablevalues.dta", clear
xtset id_num wave

g weight_all = weight_wave1sample if wave == 1
replace weight_all = weight_wave2sample if wave == 2
replace weight_all = weight_wave3sample if wave == 3

********************** DEPENDENT VARIABLES ******************************************************

****** VOTE
**** first round vote: vb20bra
**** second round vote: vb20bra2
g vote_w1 = l2.vb20bra if wave == 3 
	recode vote_w1 (4/98=4)
	lab def vote_w1 1 "Wave 1 Dilma" 2 "Wave 1 Serra" 3 "Wave 1 Marina" 4 "Wave 1 Other/Undecided"
	lab val vote_w1 vote_w1 
recode vb20bra (1/5 = 0) (88/98 = 1), g(abstainblank)
recode abstainblank (0=1) if vb20bra_cod == 1 | vb20bra_cod == 6 | vb20bra_cod == 98

********************** INDEPENDENT VARIABLES ******************************************************

****** RELIGION
tab q3c wave //DENOMINATION
tab q5a wave //FREQUENCY OF MASS
tab q5c wave //PRIEST TALKED ABOUT CAND
tab q5e wave //PRIEST SUPPORTED WHOM?
tab q5e wave, nol //PRIEST SUPPORTED WHOM?
tab gim2 wave //religious radio

recode q3c (1=1) (2 5 = 2) (4 11 = 3) (3 6 7 8 10 12 = 4) (88 98 = .), g(relig)
	lab def relig 1 "Catholic" 2 "Evangelical/Protestant" 3 "No Religion" 4 "Other Religion"
	lab val relig relig

g churchfreq = (5-q5a)/4 if q5a < 6

recode q5b (88 98 = .)
replace q5b = (4-q5b)/3
egen religimportance = mean(q5b), by(id_num)

recode q5k_cod (3 37 = 1) (105 59 = 2) (46 = 3) (18 = 4) (48 = 5) (96 97 100 101 102 103 104 = 6) (99 = .a), g(prevchurch)
	replace prevchurch = 7 if q5j == 4
	lab def prevchurch 1 "Universal" 2 "Assembly of God" 3 "Christian Congregation" 4 "Pentecostal" 5 "Evangelical" 6 "Catholic" 7 "Oldtimer"
	lab val prevchurch prevchurch
recode prevchurch (1/6 = 1) (7 = 0), g(convert)
	replace convert = 1 if q5j < 4
	replace convert = l.convert if wave == 3
	replace convert = f.convert if wave == 1
g evan_fromcath = convert
	recode evan_fromcath (1=0) if (prevchurch < 6 | relig == 1)
g evan_fromevan = convert
	recode evan_fromevan (1=0) if (prevchurch == 6)
	
g clergytalked = q5c == 1 if wave != 1
g clergysupported = q5e < 6 & q5e != 0 if wave != 1
g clergysupporteddilma = q5e == 1 if wave != 1
g clergysupportedserra = q5e == 2 if wave != 1
g clergysupportedmarina = q5e == 3 if wave != 1
	lab var clergysupporteddilma "Clergy Supported Dilma"
	lab var clergysupportedserra "Clergy Supported Serra"
	lab var clergysupportedmarina "Clergy Supported Marina"
egen clergycandidate = group(clergysupporteddilma clergysupportedserra clergysupportedmarina)
	lab def clergycand 1 "No one" 2 "Marina" 3 "Serra" 4 "Dilma"
	lab val clergycandidate clergycand
g clergycandidate_agree = (clergycandidate == 4 & vb20bra == 1) | (clergycandidate == 3 & vb20bra == 2) | (clergycandidate == 2 & vb20bra == 3) ///
		if clergycandidate > 1 & clergycandidate < 5
	
*g church_cand_agree = (vb1==church_cand_who) if church_cand_who < 6
*	recode church_cand_agree (. = 0) if church_cand_who < 6
	
	
********** CONTROLS/MODERATORS
recode q10 ing4 b20a it1 b20 b20a pol1 d5 (88 98 99 = .)
g mujer = q1-1
g tamanor = 4-tamanho
tab estratopri, g(region)

recode pol1 (1/2 = 1) (3/4 = 0), g(highinterest)
recode pol1 (1/2 = 0) (3/4 = 1), g(lowinterest)


******************************************* LEGITIMACY, TRUST
replace ing4 = (ing4-1)/6
g lag_ing4 = l2.ing4
	replace lag_ing4 = l.ing4 if wave == 2
recode lag_ing4 (0/.7 = 0) (.71/1 = 1), g(lag_ing4dichot)
g lowing4 = 1-lag_ing4dichot 

replace it1 = (4-it1)/3
g lag_it1 = l2.it1
	replace lag_it1 = l.it1 if wave == 2
recode lag_it1 (0/1 = 0) (2/3 = 1), g(hightrust)
recode lag_it1 (0/1 = 1) (2/3 = 0), g(lowtrust)

g trust_ownchurch = b20 if relig == 1
	replace trust_ownchurch = b20a if relig == 2


******************************************* POLICY ISSUES and ideology
g l1_change = l1-l2.l1 if wave == 3
g l1_lag2 = l2.l1

foreach var in d5 d6 l1 {
	recode 	`var' (88 98 = .)
	replace `var' = (`var'-1)/9
*	if (`var' == d5 | `var' == d6) replace `var' = l.`var' if wave == 2
*	if (`var' == d5 | `var' == d6) replace `var' = l2.`var' if wave == 3
}

recode abort (88 98 = .) (4 = 3)
*	replace abort = f.abort if wave == 2
*	replace abort = f2.abort if wave == 3
	replace abort = (abort-1)/2

recode ros* (88 98 = .)
corr ros1 ros2 ros3 ros4 ros5 ros6
	factor ros1 ros2 ros3 ros4 ros5 ros6
	alpha ros1 ros2 ros3 ros4 ros5 ros6, item
egen ros = rowmean(ros2 ros3 ros4 ros5 ros6)
	replace ros = (ros-1)/6
replace ros1 = (ros1-1)/6
g ros_change = ros-l.ros if wave == 2
g ros1_change = ros1-l2.ros1 if wave == 3
g ros_lag1 = l.ros if wave == 2	
g ros1_lag2 = l2.ros if wave == 3	



************************************************************************************************************************************************
************************************************************************************************************************************************
****************************************** ANALYSIS ********************************************************************************************

************ EXPLORATION: POLICY VIEWS OF CONVERTS, BEPS 2010
quietly do "C:\Users\aesmith2\Dropbox\Work\research in progress\book project\Analysis\Setup_BEPS2010.do"
reg churchfreq i.convert##i.relig 
reg religimportance i.convert##i.relig
eststo clear
forvalues i = 1/2 {
	foreach dv in abort l1 d5 d6 ros ros1 trust_ownchurch {
		reg `dv' convert churchfreq if relig == `i'
		eststo
	}
}
esttab, b(3) se(3) nopar nogaps compress nobaselevels star(^ .10 * .05 ** .01)
preserve
recode convert (1=0) if relig > 2
eststo clear
foreach dv in abort l1 d5 d6 ros ros1 {
	reg `dv' i.convert##i.relig  churchfreq
	eststo
}
esttab, b(3) se(3) nopar nogaps compress nobaselevels star(^ .10 * .05 ** .01)
restore
g current_former_cath = (relig == 1 | priorchurchcath == 1) if wave == 2 
reg abort convert if l.current_former_cath == 1
**** changes: evidence is confusing; I'm not sure what's going on with the change models, but I don't believe them.
reg l1_change i.l1.convert##i.relig
reg ros_change i.convert##i.relig
reg ros1_change i.convert##i.relig
reg l1 i.convert##i.relig l2.l1 if wave == 3
reg ros i.convert##i.relig l2.ros if wave == 3
reg ros1 i.convert##i.relig l.ros1 if wave == 2
tabstat l1 if wave == 1, by(convert)
tabstat l1 if wave == 2, by(convert)
tabstat l1 if wave == 3, by(convert)
************ END EXPLORATION: POLICY VIEWS OF CONVERTS, BEPS 2010


